#ifndef __M_CONSUME_H__
#define __M_CONSUME_H__

#include "../mqcommon/message.pb.h"
#include "../mqcommon/logger.hpp"

#include <iostream>
#include <unordered_map>
#include <mutex>
#include <vector>
#include <memory>
#include <functional>

namespace zhong
{
    // 参数：消费者标识tag 消息属性bp 消息内容body
    using ConsumerCallback = std::function<void(const std::string &, const zhong::BasicProperties *, const std::string &)>;
    struct Consumer
    {
        using ptr = std::shared_ptr<Consumer>;

        std::string tag;           // 消费者标识
        std::string queue_name;    // 订阅的队列名称
        bool auto_ack;             // 自动确认标志
        ConsumerCallback callback; // 消费处理回调函数

        Consumer()
        {
            DEBUG_LOG("获取消费者[%p]", this);
        }
        Consumer(const std::string &tag, const std::string &queue_name, bool auto_ac, const ConsumerCallback &cb)
            : tag(tag), queue_name(queue_name), auto_ack(auto_ack), callback(cb)
        {
            DEBUG_LOG("获取消费者[%p]", this);
        }
        ~Consumer()
        {
            DEBUG_LOG("删除消费者[%p]", this);
        }
    };

}
#endif